<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link href="../../css/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../js/jquery.js"></script>
    <script type="text/javascript" src="../../js/axios.js"></script>
    <script type="text/javascript" src="../../js/api.js"></script>
    <script type="text/javascript" src="../../layui/layui.js"></script>
    <link href="../../layui/css/layui.css" rel="stylesheet" type="text/css"/>
</head>

<body>
<div class="place"><span>位置：</span>
    <ul class="placeul">
        <li>采购管理</li>
        <li>采购单管理</li>
        <li>采购单详情</li>
    </ul>
</div>
<div class="formbody">
    <div class="formtitle"><span>采购单信息</span></div>
    <ul class="forminfo">
        <li>
            <label>采购单编号</label>
            <cite id="purchaseId"></cite>
        </li>
        <li>
            <label>采购时间</label>
            <cite id="purchaseTime"></cite>
        </li>
        <li>
            <label>总金额</label>
            <cite id="money"></cite><!--￥9,876,582-->
        </li>
        <li>
            <label>操作人</label>
            <cite id="creatorName"></cite><!--关羽-->
        </li>
        <li>
            <label>审核状态</label>
            <cite id="checkStatus"></cite><!--已审核通过-->
        </li>
        <li>
            <label>审核意见</label>
            <cite id="checkOpinion"></cite><!--做的很详细，同意通过-->
        </li>
        <li>
            <label>审核人</label>
            <cite id="auditName"></cite><!--曹操-->
        </li>
        <li>
            <label>审核时间</label>
            <cite id="auditTime"></cite><!--2017-01-30 12:05:05-->
        </li>
    </ul>
    <table class="tablelist">
        <thead>
        <tr>
            <th>序号</th>
            <th>品牌</th>
            <th>类型</th>
            <th>型号</th>
            <th>厂商</th>
            <th>数量</th>
            <th>单位</th>
            <th>单价</th>
            <th>金额</th>
        </tr>
        </thead>
        <tbody id="detaillist">
        <!-- <tr>
           <td>1</td>
           <td>联想</td>
           <td>笔记本电脑</td>
           <td>T470</td>
           <td>北京联想科技股份有限公司</td>
           <td>10</td>
           <td>台</td>
           <td>9998</td>
           <td>99980</td>
         </tr>
         <tr>
           <td>2</td>
           <td>联想</td>
           <td>笔记本电脑</td>
           <td>X260</td>
           <td>北京联想科技股份有限公司</td>
           <td>5</td>
           <td>台</td>
           <td>5500</td>
           <td>27500</td>
         </tr>-->
        </tbody>
    </table>
    <div style="margin-top:20px; margin-left:20px;"><!--onclick="window.history.go(-1);"-->
        <input name="" id="backbutton" type="button" class="btn" value="返回" />
    </div>
</div>
<script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');
    let parameter1 = getParameter('pageNum');
    // let parameter3 = location.href.match(/^.+condition=(.*)&.+$/);
    let parameter3 = getParameter('condition');
    $('#backbutton').click(() => {
        window.location.href = 'purchaseList.html?pageNum='+parameter1+'&condition='+parameter3
    })
    $(function () {
        loadPurchaseManageDetail()
    })
    let parameter = getParameter("purchaseId");

    //加载数据
    function loadPurchaseManageDetail() {
        axiosJson('get', '/purchase/detail', null, {purchaseId: parameter}).then((res) => {
            writePurchaseDetail(res)

        })
    }

    //写数据
    function writePurchaseDetail(res) {
        let pur = res.data.resultData;
        let status = pur.purchase.checkStatus;
        var arr = ['未审核', '审核中', '审核通过', '审核未通过'];
        for (let i = 0; i <arr.length ; i++) {
            if (status == (i + 1)) status = arr[i]
        }
        $("#purchaseId").html(parameter)      //采购单编号
        $("#purchaseTime").html(pur.purchase.purchaseTime)  //采购时间
        $("#money").html('￥' + pur.purchase.totalMoney)           //采购总金额
        $("#creatorName").html(pur.purchase.creator.uName)    //操作人
        $('#checkStatus').html(status)     //审核状态
        $('#checkOpinion').html(pur.purchase.checkOpinion)  // 审核意见
        $("#auditName").html(pur.purchase.checkUser.uName)    //审核人
        $("#auditTime").html(pur.purchase.checkTime)    //审核时间

        let pro = pur.purchaseData;
        let str = ''
        for (let i = 0; i < pro.length; i++) {
            str += '<tr>\n' +
                '                <td>' + (i + 1) + '</td>\n' +
                '                <td>' + pro[i].brandName + '</td>\n' +
                '                <td>' + pro[i].typeName + '</td>\n' +
                '                <td>' + pro[i].productModel + '</td>\n' +
                '                <td>' + pro[i].firmName + '</td>\n' +
                '                <td>' + pro[i].count + '</td>\n' +
                '                <td>' + pro[i].productUnit + '</td>\n' +
                '                <td>' + pro[i].purchasePrice + '</td>\n' +
                '                <td>' + pro[i].totalMoney + '</td>\n' +
                '            </tr>'
        }
        $('#detaillist').html(str)
        $('.tablelist tbody tr:odd').addClass('odd');
    }


</script>
</body>
</html>
